package com.ganlebao.study.springcloudfeignclient.basic;

import com.ganlebao.study.springcloudfeignclient.basic.acl.LocalRemoteServer;
import com.ganlebao.study.springcloudfeignclient.basic.dto.User;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;

@RestController
@RequestMapping("feign-test")
public class FeignProfileTestController {
    @Autowired
    private LocalRemoteServer remoteServer;

    @Autowired
    private ExceptionFeignClient feignClient;

    /**
     * 查询github的仓库信息
     *
     * @param
     * @return
     */
    @RequestMapping("multi-param")
    public String queryRepositoryInfo() {
        User user = new User();
        user.setAge(18);
        user.setName("甘乐保");
        //
        Optional<String> result = feignClient.query(() -> remoteServer.echoUser(user));
        if (result.isPresent()) {
            return result.get();
        } else {
            return "获取内容为空";
        }
    }

}
